# Purpose of this instance
# Use "production", "devel", "local" or "test"
ENV="{% if devel %}devel{% else %}{{ env }}{% endif %}"

# Directory and files where is stored Copr database files
DATA_DIR = '/var/lib/copr/data'
DATABASE = '/var/lib/copr/data/copr.db'

# Stage runs against staging FAS/OpenID
OPENID_PROVIDER_URL = "https://id{% if devel %}.stg{% endif %}.fedoraproject.org"
OPENID_STORE = '/var/lib/copr/data/openid_store'

WHOOSHEE_DIR = '/var/lib/copr/data/whooshee'
WHOOSHEE_MIN_STRING_LEN = 2
WHOOSHEE_WRITER_TIMEOUT = 10

SECRET_KEY = '{{ copr_secret_key }}'
{% if env == 'production' %}
BACKEND_PASSWORD = '{{ copr_backend_password  }}'
{% elif devel %}
BACKEND_PASSWORD = '{{ copr_backend_password_dev }}'
{% else %}
BACKEND_PASSWORD = '{{ copr_backend_password_stg }}'
{% endif %}

BACKEND_BASE_URL = '{{ backend_base_url }}'

BACKEND_STATS_URI = "/stats/index.html"

# restrict access to a set of users
#USE_ALLOWED_USERS = False
#ALLOWED_USERS = ['bonnie', 'clyde']

SQLALCHEMY_DATABASE_URI = 'postgresql+psycopg2://copr-fe:{{ copr_database_password }}@/coprdb'

# Token length, defaults to 30 (max 255)
#API_TOKEN_LENGTH = 30

# Expiration of API token in days
#API_TOKEN_EXPIRATION = 180

# logging options
#SEND_LOGS_TO = ['root@localhost']
{% if devel %}
LOGGING_LEVEL = 'debug'
{% endif %}

DEBUG = False
SQLALCHEMY_ECHO = False

CSRF_ENABLED = True
WTF_CSRF_ENABLED = True

# send emails when user's perms change in project?
SEND_EMAILS = True

{% if copr_kerberos_auth_enabled %}
KRB5_LOGIN = {
   'log_text':     "gssapi-login",
   'email_domain': "fedoraproject.org",
}
{% endif %}

PUBLIC_COPR_HOSTNAME = "{{ copr_frontend_public_hostname }}"

# When running the website through apache,
# this variable is automatically set from ServerName
# in the httpd config. Setting it in this file is needed
# for manage.py purposes
SERVER_NAME = "{{ copr_frontend_public_hostname }}"


LOG_FILENAME = "/var/log/copr-frontend/frontend.log"
LOG_DIR = "/var/log/copr-frontend/"

# to accept stat events from logstash
INTRANET_IPS = {{ copr_backend_ips }}

REPO_GPGCHECK = 1

{% if env == 'staging' %}
PUBLIC_COPR_BASE_URL = "https://copr.stg.fedoraproject.org"
{% else %}
PUBLIC_COPR_BASE_URL = "https://copr.fedorainfracloud.org"
{% endif %}

{% if env == 'staging' %}
# Staging URLs for fedmenu
FEDMENU_URL = "https://apps.stg.fedoraproject.org/fedmenu/"
FEDMENU_DATA_URL = "https://apps.stg.fedoraproject.org/js/data.js"
{% else %}
# Production URLs for fedmenu
FEDMENU_URL = "https://apps.fedoraproject.org/fedmenu/"
FEDMENU_DATA_URL = "https://apps.fedoraproject.org/js/data.js"
{% endif %}

# todo: check that ansible variable is used correctly
{% if env == 'staging' %}
ENFORCE_PROTOCOL_FOR_BACKEND_URL = "https"
ENFORCE_PROTOCOL_FOR_FRONTEND_URL = "https"
{% else %}
ENFORCE_PROTOCOL_FOR_BACKEND_URL = "https"
ENFORCE_PROTOCOL_FOR_FRONTEND_URL = "https"
{% endif %}

DIST_GIT_URL="https://{{ dist_git_base_url }}/cgit"
DIST_GIT_CLONE_URL="https://{{ dist_git_base_url }}/git"
COPR_DIST_GIT_LOGS_URL = "https://{{ dist_git_base_url }}/per-task-logs"

# no need to filter cla_* groups, they are already filtered by fedora openid
GROUP_DENYLIST = ['fedorabugs', 'packager', 'provenpackager', 'ipausers', 'signed_fpca', 'fedora-contributor']
# TODO: remove BLACKLISTED_GROUPS once # https://pagure.io/copr/copr/pull-request/1960 is released
BLACKLISTED_GROUPS = GROUP_DENYLIST

DEFER_BUILD_SECONDS = 300

ENABLE_DISCUSSION = True
DISCOURSE_URL = "https://discussion.fedoraproject.org/"

# We may have a (temporary) chroot that doesn't correspond with /etc/os-release
# on a client system, e.g. "rhelbeta-8" chroots in Copr which doesn't match to
# any real system, instead it is a temporary alias for "epel-8". In such case,
# set this to {"epel-8": "rhelbeta-8"}
CHROOT_NAME_RELEASE_ALIAS = {"epel-8": "rhelbeta-8"}
{% if allowlist_emails is defined %}

ALLOWLIST_EMAILS = [
{% for recipient in allowlist_emails %}
  "{{ recipient }}",
{% endfor %}
]
{% endif %}

PAGURE_EVENTS = {
{% if copr_pagure_events is defined %}
{% for instance, url in copr_pagure_events.items() %}
{% for topic in [
  'git.receive',
  'pull-request.new',
  'pull-request.rebased',
  'pull-request.updated',
  'pull-request.comment.added'] %}
  '{{ instance }}.{{ topic }}' : '{{ url }}',
{% endfor %}
{% endfor %}
{% endif %}
}

# Increase build timeout to 48h
# Requested by lantw44 for chromium
MAX_BUILD_TIMEOUT = 172800
{% if copr_kerberos_auth_enabled %}
API_GSSAPI_AUTH = True
{% else %}
API_GSSAPI_AUTH = False
{% endif %}

{% if env == 'production' %}
FAS_SIGNUP_URL = "https://accounts.fedoraproject.org"
{% else %}
FAS_SIGNUP_URL = "https://accounts.stg.fedoraproject.org"
{% endif %}
